package ui;

import service.Imp.ServiceLogicImp;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class show {
    public static void main(String[] args) {
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd hh:mm:ss");

        while(true){
            Scanner scanner = new Scanner(System.in);
            ServiceLogicImp serviceLogicImp = new ServiceLogicImp();
            System.out.println("---------------零钱通菜单----------------");
            System.out.println("1.零钱通明细");
            System.out.println("2.收益入账");
            System.out.println("3.消费");
            System.out.println("4.退出");
            System.out.println("请输入你的选项(1-4):");
            try {
                int menu = scanner.nextInt();
                switch(menu){//1
                    case 1:{
                        serviceLogicImp.findAllService();
                        break;//终止switch块，防止执行后续case分支
                    }
                    case 2:{
                        System.out.println("请输入收益来源：");
                        String project = scanner.next();
                        System.out.println("请输入变更金额：");
                        double amount = scanner.nextDouble();
                        System.out.println("变更时间是：");
                        String format = simpleDateFormat.format(date);
                        System.out.println(format);
                        serviceLogicImp.addAmountService(project,amount,format);
                        break;
                    }
                    case 3:{
                        System.out.println("请输入收款方：");
                        String project = scanner.next();
                        System.out.println("请输入变更金额：");
                        double amount = scanner.nextDouble();
                        System.out.println("变更时间是：");
                        String format = simpleDateFormat.format(date);
                        System.out.println(format);
                        serviceLogicImp.consumeAmountService(project,amount,format);
                        break;
                    }
                    case 4:{
                        System.out.println("---你退出了零钱通---");
                        System.exit(0);//终止当前正在运行的 Java 虚拟机（JVM）的方法，参数为0表示正常退出
                    }
                    default:{
                        System.out.println("---无效指令，请输入一个1-4的指令操作---");
                    }
                }
            } catch (Exception e) {
//                System.out.println("你在乱输什么！");
                e.printStackTrace();
            }
        }
    }
}
